//
//  CollectionViewCell.m
//  Cat
//
//  Created by lushitong on 2018/12/13.
//  Copyright © 2018年 lushitong. All rights reserved.
//

#import "CollectionViewCell.h"
#import "FLImageView.h"

@interface CollectionViewCell()

@property (nonatomic, strong) FLImageView *picImageView;
@property (nonatomic, strong) UILabel *nameLabel;

@end

@implementation CollectionViewCell

- (void)setInfoModel:(CategoryInfo *)infoModel {
	self.nameLabel.text = infoModel.name;
	[self.picImageView setImageUrl:[NSURL URLWithString:infoModel.iconURL] size:CGSizeMake(kQKFitModuleFloor(51.0), kQKFitModuleFloor(51.0)) cornerRadius:0.0];
}

- (instancetype)initWithFrame:(CGRect)frame {
	self = [super initWithFrame:frame];
	if (self) {
		[self loadAllView];
	}
	return self;
}

- (void)loadAllView {
	[self.contentView addSubview:self.picImageView];
	[self.contentView addSubview:self.nameLabel];
	[self.picImageView mas_makeConstraints:^(MASConstraintMaker *make) {
		make.size.equalTo(CGSizeMake(kQKFitModuleDecimal(51), kQKFitModuleDecimal(51)));
		make.center.equalTo(self.contentView);
	}];
	
	[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
		make.centerX.equalTo(self.contentView.mas_centerX);
		make.bottom.equalTo(self.contentView.mas_bottom);
	}];
}

#pragma mark----- lazy init -----

- (FLImageView *)picImageView {
	if (!_picImageView) {
		_picImageView = [[FLImageView alloc] init];
		_picImageView.backgroundColor = [UIColor whiteColor];
		_picImageView.userInteractionEnabled = NO;
	}
	return _picImageView;
}

- (UILabel *)nameLabel {
	if (!_nameLabel) {
		_nameLabel = [UILabel labelWithFont:[UIFont systemFontOfSize:kQKFitFont(10)] textColor:COLOR_WITH_HEX(0x756D68)];
		_nameLabel.text = @"hello";
	}
	return _nameLabel;
}


@end
